Requesting
class FirstActivity : Activity() {
val startForResult = registerForActivityResult(StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK)
}
fun onUserStartedSomething() {
startForResult.launch(Intent(this, SecondActivity::class.java))
}
}
Toute Activity a une propriété intent
qui a permis de la créer:
class SecondActivity : Activity() {
fun onUserFinishedSomething() {
intent.putExtra("reply_key", "reply data")
setResult(RESULT_OK, intent)
finish()
}
}
Creating a custom contract